package com.example.booksystem.service;

import com.example.booksystem.dao.BookDao;
import com.example.booksystem.model.BookInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

import java.util.List;
//service调用dao
@Service
public class BookService {
    @Autowired
    private BookDao bookDao;//移动至此方便后续增加功能
    public List<BookInfo> getList(){
        //1.获取图书数据
        //2.对图书数据进行处理
        //3.返回数据
        List<BookInfo> books = bookDao.mockData();
        //mockData()传入虚假数据
        for (BookInfo x:books) {
            if (1 == x.getStatus()){
                x.setStatusCN("可借阅");
            }else {
                x.setStatusCN("不可借阅");
            }
        }
        return books;
    }
}
